package cn.backpackerxl.easyJDBC.util;

import cn.backpackerxl.easyJDBC.annotation.Table;

import java.util.Date;


/**
 * @Author:backpackerxl CreateTime:2022/4/16
 * FileName:Log
 **/
public final class Logger {
    public static void logger(Object obj, JDBC type, String sql) {
        if (obj.getClass().isAnnotationPresent(Table.class)) {
            if (obj.getClass().getDeclaredAnnotation(Table.class).show()) {
                System.out.println("[ \033[34m" + type + " INFO\033[0m ]\t\033[32m:: \033[0m" + BasicUtil.formatTime(new Date(), "yyyy-MM-dd HH:mm:ss SSS") + "\033[32m ::\033[0m \033[36mSQL\033[0m -> " + sql);
            }
        }
    }

    public static void logger(String msg) {
        System.out.println(BasicUtil.formatTime(new Date(), "yyyy-MM-dd HH:mm:ss SSS") + " INFO " + msg);
    }

    public static void error(String msg) {
        System.err.println(BasicUtil.formatTime(new Date(), "yyyy-MM-dd HH:mm:ss SSS") + " INFO " + msg);
    }
}
